var T = this;

var cur = function() {
	return $('#s-tl>.s-cur');
}

var searh_d = 0;

$("#kw").focus();

$('#s-tl>a').click(function() {
	if ($(this) === T.cur()) return;
	T.cur().removeClass('s-cur');
	$(this).addClass('s-cur');
	searh_d = $(this).attr("alt");
}).eq(0).click();

function form_s() {
	if($("input[@type=radio][checked]").val() == 0) {
		google_s();
	} else {
		baidu_s();
	}
	return true;
}
var google_s = function () {
	var c = searh_d;
	var url;
    $('#g_val').val($('#kw').val());

	if(c == 0) {
		 url = "http://www.google.com.hk/search";
		 $('#tab').value = 'vw';
		 $('#tbs').value = '';
	}
	if(c == 1) {
		 url = "http://www.google.cn/music/search";
	}
	if(c == 2) {
		 url = "http://images.google.com.hk/images";
	}
	if(c == 3) {
		url = "http://www.google.com.hk/search";
		$('#tab').value = 'nv';
		$('#tbs').value = 'vid:1';
	}
	if(c == 4) {
		url = "http://www.google.com.hk/search";
		$('#tab').value = 'wn';
		$('#tbs').value = 'nws:1';
	}
	if(c == 5) {
		url = "http://ditu.google.cn/maps";
		$('#tab').value = 'vl';
	}
	document.f.action = url;
}
var baidu_s = function () {
	var c = searh_d;
	var url;
	if(c == 0) {
		 url = "http://www.baidu.com/baidu";
		 $('#search_hidden').innerHTML = '<input value="mengyaoren" name="tn" type="hidden">';
	}
	if(c == 1) {
		 url = "http://www.baidu.com/m";
		 $('#search_hidden').innerHTML = '<input value="baidump3" name="tn" type="hidden"><input value="134217728" name="ct" type="hidden"><input value="hao123" name="sc" type="hidden">';
	}
	if(c == 2) {
		 url = "http://image.baidu.com/i";
		 $('#search_hidden').innerHTML = '<input value="baiduimage" name="tn" type="hidden"><input value="201326592" name="ct" type="hidden"><input value="2" name="cl" type="hidden"><input value="-1" name="lm" type="hidden"><input value="hao123" name="fm" type="hidden">';
	}
	if(c == 3) {
		 url = "http://video.baidu.com/v";
		 $('#search_hidden').innerHTML = '<input value="mengyaoren" name="sc" type="hidden">';
	}
	if(c == 4) {
		url = "http://news.baidu.com/ns";
		$('#search_hidden').innerHTML = '<input value="news" name="tn" type="hidden"><input value="mengyaoren" name="sc" type="hidden">';
	}
	if(c == 5) {
		url = "http://map.baidu.com/m";
		$('#search_hidden').innerHTML = '';
	}
	document.f.action = url;
}